﻿@using System.Web.UI.WebControls
@using DevExpress.Web.Mvc.UI
@using Dogshow.Web.Controllers
@using Dogshow.Web.Utils
@using Dogshow.Model
@model Pas
@{
    ViewBag.Title = "Dogshow - pas";
}
<script src="@Url.Content("~/Scripts/imageupload.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/Korisnik/psi.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/Korisnik/kinolozi.js")" type="text/javascript"></script>
<style>
    #imageWrapper 
    {
        float: left;
        width: 229px;
        height: 0;
    }
    #form 
    {
        float: left;
        margin-left: 250px;
    }
</style>

<div>
    @using (Html.BeginForm("SacuvajPsa", "Psi", FormMethod.Post, new { @class = "edit_form" }))
    {
        <div id="imageWrapper">
            @Html.DevExpress().Image(img =>
       {
           img.Name = "ImagePreview";
           img.ImageUrl = Model.SlikaPsa;
           img.Properties.AlternateText = "Slika psa";
           img.Width = Unit.Pixel(229);
           img.Height = Unit.Pixel(200);
       }).GetHtml()
            @Html.HiddenFor(x => x.SlikaPsa)
            @Html.DevExpress().UploadControl(upload =>
       {
           upload.Name = "Upload";
           upload.Width = Unit.Percentage(100);
           upload.ShowUploadButton = true;
           upload.ShowProgressPanel = true;
           upload.UploadButton.Text = "Pošalji";
           upload.ValidationSettings.Assign(PsiController.ImageValidationSettings);
           upload.CallbackRouteValues = new { Controller = "Psi", Action = "SacuvajSlikuPsa", Area = "" };
           upload.ClientSideEvents.FileUploadComplete = "onFileUploadComplete";

       }).GetHtml()
        </div>
        
        <div id="form">
            @Html.HiddenFor(x => x.Id)
            <div class="line">
                @Html.DevExpress().Label(
                            s =>
                            {
                                s.ControlStyle.CssClass = "label";
                                s.Text = "Rasa:";
                                s.AssociatedControlName = "IdRase";
                            }
                        ).GetHtml()
                @Html.PartialOrNull("_RasePasaComboBox", Model.IdRase)
            </div>
            <div class="line">
                @Html.DevExpress().Label(s =>
                {
                    s.Text = "Broj rodovnika:";
                    s.AssociatedControlName = "BrojRodovnika";
                    s.ControlStyle.CssClass = "label";
                }).GetHtml()
                @Html.DevExpress().TextBox(s =>
                {
                    s.Name = "BrojRodovnika";
                    s.ControlStyle.CssClass = "editor";
                    s.Properties.ConvertEmptyStringToNull = true;
                    s.ShowModelErrors = true;
                }).Bind(Model.BrojRodovnika).GetHtml()
            </div>
            <div class="line">
                @Html.DevExpress().Label(s =>
                {
                    s.Text = "Ime:";
                    s.AssociatedControlName = "ImePsa";
                    s.ControlStyle.CssClass = "label";
                }).GetHtml()
                @Html.DevExpress().TextBox(s =>
                {
                    s.Name = "ImePsa";
                    s.ControlStyle.CssClass = "editor";
                    s.ShowModelErrors = true;
                }).Bind(Model.ImePsa).GetHtml()
            </div>
            <div class="line">
                @Html.DevExpress().Label(s =>
                {
                    s.ControlStyle.CssClass = "label";
                    s.Text = "Pol:";
                    s.AssociatedControlName = "Pol";
                }).GetHtml()
                @Html.DevExpress().RadioButtonList(s =>
                {
                    s.Name = "Pol";
                    s.Properties.TextField = "Naziv";
                    s.Properties.ValueField = "Id";
                    s.Properties.ValueType = typeof(int);
                    s.Properties.RepeatDirection = RepeatDirection.Horizontal;
                    s.ControlStyle.CssClass = "editor";
                    s.ShowModelErrors = true;
                }).BindList(new[] { new { Id = 1, Naziv = "Mužjak" }, new { Id = 2, Naziv = "Ženka" } }).Bind(Model.Pol).GetHtml()
                <div class="line">
                    @Html.DevExpress().Label(s =>
                    {
                        s.Text = "Oštenjen:";
                        s.AssociatedControlName = "Ostenjen";
                        s.ControlStyle.CssClass = "label";
                    }).GetHtml()
                            @Html.DevExpress().DateEdit(s =>
                    {
                        s.Name = "Ostenjen";
                        s.ControlStyle.CssClass = "editor";
                        s.ShowModelErrors = true;
                    }).Bind(Model.Ostenjen).GetHtml()
                </div>
            </div>
            <div class="line">
                @Html.DevExpress().Label(s =>
                {
                    s.Text = "Boja:";
                    s.ControlStyle.CssClass = "label";
                    s.AssociatedControlName = "Boja";
                }).GetHtml()
                @Html.DevExpress().TextBox(s =>
                {
                    s.Name = "BojaDlake";
                    s.ControlStyle.CssClass = "editor";
                    s.Properties.ConvertEmptyStringToNull = true;
                    s.ShowModelErrors = true;
                }).Bind(Model.BojaDlake).GetHtml()
            </div>
            <div class="line">
                @Html.DevExpress().Label(s =>
                {
                    s.Text = "Tip dlake:";
                    s.ControlStyle.CssClass = "label";
                    s.AssociatedControlName = "TipDlake";
                }).GetHtml()
                @Html.DevExpress().TextBox(s =>
                {
                    s.Name = "TipDlake";
                    s.ControlStyle.CssClass = "editor";
                    s.Properties.ConvertEmptyStringToNull = true;
                    s.ShowModelErrors = true;
                }).Bind(Model.TipDlake).GetHtml()
            </div>
            <div class="line">
                @Html.DevExpress().Label(s =>
                {
                    s.Text = "Visina [cm]:";
                    s.ControlStyle.CssClass = "label";
                    s.AssociatedControlName = "Visina";
                }).GetHtml()
                @Html.DevExpress().TextBox(s =>
                {
                    s.Name = "Visina";
                    s.ControlStyle.CssClass = "editor";
                    s.Properties.ConvertEmptyStringToNull = true;
                    s.ShowModelErrors = true;
                }).Bind(Model.Visina).GetHtml()
            </div>
            <div class="line">
                @Html.DevExpress().Label(s =>
                {
                    s.Text = "Težina [kg]:";
                    s.ControlStyle.CssClass = "label";
                    s.AssociatedControlName = "Tezina";
                }).GetHtml()
                @Html.DevExpress().TextBox(s =>
                {
                    s.Name = "Tezina";
                    s.ControlStyle.CssClass = "editor";
                    s.Properties.ConvertEmptyStringToNull = true;
                    s.ShowModelErrors = true;
                }).Bind(Model.Tezina).GetHtml()
            </div>
            <div class="line">
            @Html.DevExpress().Label(s =>
                {
                    s.Text = "Vlasnik:";
                    s.ControlStyle.CssClass = "label";
                    s.AssociatedControlName = "IdVlasnika";
                }).GetHtml()
            @Html.PartialOrNull("_KinologComboBox", Model.IdVlasnika, new ViewDataDictionary(){{"settings", ViewBag.PodesavanjaComboBoxaVlasnikaPsa}})
        </div>
            <div class="line">
                @Html.DevExpress().Label(s =>
                {
                    s.Text = "Odgajivač:";
                    s.ControlStyle.CssClass = "label";
                    s.AssociatedControlName = "IdOdgajivaca";
                }).GetHtml()
               @Html.PartialOrNull("_KinologComboBox", Model.IdOdgajivaca, new ViewDataDictionary() { { "settings", ViewBag.PodesavanjaComboBoxaOdgajivacaPsa } })
            </div>
            <div class="line">
                @Html.DevExpress().Label(label =>
                {
                    label.Text = "Otac:";
                    label.ControlStyle.CssClass = "label";
                    label.AssociatedControlName = "IdOca";
                }).GetHtml()
                @Html.PartialOrNull("_PasComboBox", Model.IdOca, new ViewDataDictionary { { "settings", ViewData["OtacPsaComboBoxSettings"] } })
            </div>
            <div class="line">
                @Html.DevExpress().Label(label =>
                {
                    label.Text = "Majka:";
                    label.ControlStyle.CssClass = "label";
                    label.AssociatedControlName = "IdMajke";
                }).GetHtml()
                @Html.PartialOrNull("_PasComboBox", Model.IdMajke, new ViewDataDictionary { { "settings", ViewData["MajkaPsaComboBoxSettings"] } })
            </div>
            <div class="line">
                @Html.DevExpress().Button(s =>
                {
                    s.Name = "btnSave";
                    s.Text = "Sačuvaj";
                    s.ControlStyle.CssClass = "btnSave";
                    s.ClientSideEvents.Click = "onSubmit";
                }).GetHtml()
            </div>
        </div>
        
        
    }
</div>
